import { Inject, Injectable } from '@nestjs/common';
import { Model } from 'mongoose';
import { User } from '../../database/schemas/user.schema';
import { Constants } from '../../constants/constants';
import { AppService } from '../app.service';
import { UserDto } from './user.dto';
import { UserSetting } from '../../database/schemas/user-setting.schema';

@Injectable()
export class UsersService extends AppService<User, UserDto> {
  constructor(
    @Inject(Constants.MODELS.USER) private readonly userModel: Model<User>,
    @Inject(Constants.MODELS.USER_SETTING)
    private readonly settingModel: Model<UserSetting>
  ) {
    super(userModel);
  }

  async findByName(username: string): Promise<User> {
    return this.userModel.findOne({ username }).exec();
  }
}
